home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / PROGRAMM / DB_CLIPP / 0264.ZIP / BASWIND.DOC < prev    next >
Text File  |  1985-10-28  |  25KB  |  482 lines

  1.                                   BASWIND.MRG
  2.  
  3.                    POP-UP WINDOWS FOR COMPILED BASIC PROGRAMS
  4.  
  5.                                       by
  6.  
  7.                                   Dave Evers
  8.                              2500 Larch Rd. #58
  9.                               Quincy, IL  62301
  10.  
  11.                            using CALLS to ADBVAS.LIB
  12.                                       by
  13.                                Thomas Hanlin III
  14.  
  15.  
  16.          BASWIND.MRG is a general purpose BASIC subroutine which can be
  17.          incorporated into Compiled BASIC programs to allow for simple
  18.          windowing capability with a minimum of programming effort. By
  19.          "simple" I really do mean simple: about the only thing this sub-
  20.          routine does is put the window on the screen. What you do with
  21.          the window, what you put in it, and what you do with it once
  22.          you're done is all up to you. However, it does give you the
  23.          ability to make your compiled programs look "high-tech"; even
  24.          if your programming isn't.
  25.  
  26.          I wish I could take full credit for all of the capabilities of
  27.          BASWIND.MRG. The truth is, however, that very little of the
  28.          "meat" of this program is my doing. BASWIND.MRG relies heavily
  29.          on the routines in the excellent assembly language library of
  30.          advanced BASIC functions contained in ADVBAS.LIB. Perhaps the
  31.          most important of these features is the XQPRINT command, which
  32.          writes data to the screen extremely quickly. It is this command
  33.          which makes the BASWIND subroutine useful because entire sec-
  34.          tions of the screen can rapidly be "painted" into a colored,
  35.          framed "window" in a fraction of a second. 
  36.  
  37.          True windowing, of course, involves much more than just making a
  38.          box appear quickly on the screen. Programs such as TopView,
  39.          Microsoft Windows, Desq, and others allow such features as
  40.          treating the windows as virtual screens with relative cursor
  41.          positioning and independent scrolling; multiple layers of
  42.          overlapping panels that can be added and removed from a screen
  43.          while leaving the underlying data undisturbed, and delegating
  44.          the screen output from multiple programs to their assigned
  45.          windows. BASWIND.MRG is not likely to put these companies out of
  46.          business. (For that matter, it's not likely going to put me in
  47.          business, either). However, other features of the ADVBAS library
  48.          can be combined with the BASWIND.MRG subroutine to allow at
  49.          least a small percentage of these features to be incorporated
  50.          into your programs. Commands are included in ADVBAS.LIB to save
  51.          and restore the screen to an array; scroll a rectangular section
  52.          of the screen up or down or clear it; print to the screen rapid-
  53.          ly, and many other useful functions. Virtually any program that
  54.          is compiled can benefit in some way from ADVBAS.LIB; and hope-
  55.          fully, from BASWIND.MRG as well.
  56.  
  57.          ADVBAS.LIB was written by Thomas Hanlin III, and I and the rest
  58.          of the PC users community owe a debt of gratitude to this talen-
  59.          ted and generous man for his contribution to the free distribu-
  60.          tion of knowledge. Mr. Hanlin, our hats are off to you!
  61.  
  62.          INSTALLING BASWIND.MRG
  63.  
  64.          Before you can take advantage of the capabilities of this sub-
  65.          routine, of course, you must MERGE it into your BASIC program.
  66.          BASWIND is distributed as a .MRG file in ASCII format to allow
  67.          it to be easily added to any program. Just load your program
  68.          into memory, and then type:
  69.  
  70.                                LIST 55000-55590
  71.  
  72.          at the command level. This will tell you if your program uses
  73.          line numbers that BASWIND might conflict with. BASWIND uses line
  74.          numbers beginning at 55000 and ending at 55590; so obviously if
  75.          your program already uses these line numbers you should renumber
  76.          the .MRG file to another area not used in your program before
  77.          MERGEing it. Once you have done this, or if the response to the
  78.          above query indicates your program will have no problems, simply
  79.          type:
  80.  
  81.                                MERGE BASWIND.MRG
  82.  
  83.          After a few seconds, the BASIC ready prompt will return and
  84.          BASWIND will be integrated into your program. Before you do any-
  85.          thing else, SAVE your program so that your working copy will
  86.          have BASWIND installed. Then you're ready to start taking
  87.          advantage of the advanced and awesome (ahem!) capabilities of
  88.          the subroutine.
  89.  
  90.          USING BASWIND
  91.  
  92.          BASWIND is invoked, like any other BASIC subroutine, by the
  93.          GOSUB command. If you MERGEd BASWIND as distributed, you would
  94.          use GOSUB 55000. If you had to renumber the subroutine, of
  95.          course, you would use the new beginning line number in your
  96.          GOSUB statement. However, in order to get anything useful out of
  97.          the module (and probably in order to keep your program from
  98.          locking up), you first have to set up some parameters that the
  99.          subroutine will use. This is done by making assignments to the
  100.          following variables prior to the GOSUB statement:
  101.  
  102.                 ULR - (Upper Left-hand Row) - the screen row of the Upper
  103.                       Left-hand corner of your desired window. Value
  104.                       should be between 2 and 23  (for reasons explained
  105.                       below). WARNING - the subroutine does not check for
  106.                       proper values. You must check these yourself or ac-
  107.                       cept the consequences.
  108.  
  109.                 ULC - (Upper Left-hand Column) - the screen column of the
  110.                       Upper Left-hand corner. Value should be between 2
  111.                       and 79.
  112.  
  113.                 LRR - (Lower Right-hand Row) - the screen row of the Low- 
  114.                       er Right-hand corner of your window. Value should 
  115.                       be greater than ULR but less than 23.
  116.  
  117.                 LRC - (Lower Right-hand Column) - The screen column loc-
  118.                       ation of the Lower Right-hand corner. Value should
  119.                       be greater than ULC but less than 79.
  120.  
  121.               FRAME - A number between 1 and 4 indicating the type of 
  122.                       frame to be drawn around your window. Valid frame
  123.                       values are:
  124.  
  125.                          1 - Single Line Frame
  126.  
  127.                          2 - Double Line Frame
  128.  
  129.                          3 - Single Horizontal Line, Double Vertical
  130.                              Line Frame
  131.  
  132.                          4 - Single Vertical Line, Double Horizontal
  133.                              Line Frame
  134.  
  135.                        NOTE: The frame is drawn * around * the window
  136.                              coordinates specified in ULR,ULC,LRR, and
  137.                              LRC. Thus, the dimensions of your window
  138.                              will actually be two columns greater in
  139.                              width (one on each side) and two rows 
  140.                              greater in length (top and bottom). This
  141.                              is why you should make allowances in the
  142.                              value of the window corners. Allowing the
  143.                              frame to fall outside proper values will
  144.                              cause unpredictable results.
  145.  
  146.                FORE - The color of the frame in the window. Standard
  147.                       color attributes are used (Black=0, Blue=1, etc.)
  148.                       and valid values are 0 to 15.
  149.  
  150.                BACK - The actual color of the window panel. The area de-
  151.                       fined by the corners of the window will be cleared
  152.                       to spaces in the background color specified. Val-
  153.                       ues considered valid are 0 through 7.
  154.  
  155.                GROW - A "switch" used to indicate to the subroutine if 
  156.                       the window should "grow" from a small box at the
  157.                       midpoints of the coordinates to full size. A value
  158.                       of 1 indicates the window should grow. A value of
  159.                       0 indicates it should not. The "growing" illusion
  160.                       is most effective for windows of medium size; and
  161.                       is better suited to "wide" windows rather than
  162.                       "tall" ones.
  163.  
  164.              SHADOW - Another "switch" to indicate if the window should
  165.                       have a black "shadow" under it offset down and to
  166.                       the left. This gives a three-dimensional effect
  167.                       that seems to "raise" the window away from the
  168.                       screen. A value of 1 indicates a shadow is desired
  169.                       while a value of 0 means no shadow.
  170.  
  171.                       WARNING - Adding a shadow to the window increases
  172.                                 the effective window size by 3 columns
  173.                                 to the left of the window and 1 row
  174.                                 below. These additions must be consid-
  175.                                 ered when assigning the corner values
  176.                                 since invalid values that fall off the
  177.                                 screen will produce unpredictable
  178.                                 results.
  179.  
  180.                        NOTE: Windows that grow and windows with shadows
  181.                              are mutually exclusive. That is, a window
  182.                              that is desired to grow cannot have a shad-
  183.                              ow. The on-screen effect of such a combin-
  184.                              ation was determined to be undesireable.
  185.                              The "grow" switch takes precedence. If a
  186.                              window is created which calls for both a
  187.                              shadow and a growing attribute, the shadow
  188.                              will be cancelled and the window will grow.
  189.  
  190.             
  191.              LABEL$ - A character string that will serve as a label for
  192.                       the window. The label will appear in the top line
  193.                       of the frame on the left-hand side, enclosed by
  194.                       square brackets ([ ]). If the length of the label
  195.                       is greater than the width of the window, the label
  196.                       will be omitted. The attributes for the label are
  197.                       the same as for the window frame.
  198.  
  199.  
  200.          All of the above variables (with the exception of LABEL$) must
  201.          either be declared globally as integers by means of a DEFINT
  202.          statement early in the program; or must have the specific
  203.          integer identifier (%) attached wherever they appear in the
  204.          program. The BASIC compiler is picky about this; so be sure to
  205.          verify that the type assignment is correct.
  206.          
  207.          EXAMPLE
  208.  
  209.          To produce a window with a blue background, a bright white
  210.          single line frame, and a label of "Ye Olde Window"; between
  211.          columns 20 and 60 and rows 4 to 20, the following statements
  212.          would be required:
  213.  
  214.               100 ULC=21:ULR=5:LRC=59:LRR=19:FORE=15:BACK=1:FRAME=1
  215.               110 SHADOW=0:GROW=0:LABEL$="Ye Olde Window"
  216.               120 GOSUB 55000
  217.  
  218.          To generate a green window with a black single horizontal,
  219.          double vertical line frame, with a shadow; the following
  220.          statements would be needed:
  221.  
  222.                200 ULC=13:ULR=3:LRC=45:LRR=15:FORE=0:BACK=2:FRAME=3
  223.                210 SHADOW=1:GROW=0:LABEL$=""
  224.                220 GOSUB 55000
  225.  
  226.          To "grow" a cyan panel in the middle of the screen with a
  227.          yellow double line frame, the program would make the following
  228.          call:
  229.  
  230.                300 ULC=10:ULR=5:LRC=70:LRR=19:FORE=14:BACK=3:FRAME=2
  231.                310 SHADOW=0:GROW=1:LABEL$=""
  232.                320 GOSUB 55000
  233.  
  234.          Of course, once the window is placed on the screen, it is up to
  235.          you to fill it with data by means of LOCATE, COLOR, and PRINT
  236.          statements. The above window calls only give you the canvas on
  237.          which to work. You, as the artist, produce the masterpiece on
  238.          your own.
  239.  
  240.          ADVANCED WINDOWING FUNCTIONS
  241.  
  242.          The basic BASWIND subroutine calls give you a fair amount of
  243.          flexibility in producing simple windows on the screen; but to
  244.          really add some "pizzazz" to your programs, you need more
  245.          capability than just these humble beginnings. This is where some
  246.          of the additional features in the ADVBAS library come into play.
  247.  
  248.          By combining some of these functions with the easily-used
  249.          BASWIND subroutine, some very powerful and exciting possibili-
  250.          ties are generated. Actually, compiled BASIC becomes a very
  251.          effective development medium with some impressive capabilities
  252.          when all of these advanced tools are put to use.
  253.  
  254.          Making "Pop-ON/Pop-OFF Windows"
  255.  
  256.          Most programs which use windows make very effective use of the
  257.          screen by allowing a window to "pop on" to the screen over the
  258.          existing information, display some important data such as help
  259.          or statistics, and then "pop off" on demand; leaving the screen
  260.          data undisturbed. Obviously, the simple commands introduced
  261.          earlier would not be of use by themselves because they destroy
  262.          the information on the screen at the window coordinates. In
  263.          order to allow "non-destructive" windows on the screen, the
  264.          contents of the screen must be saved prior to adding the window,
  265.          and then quickly restored when the window is removed.
  266.  
  267.          Fortunately, the ADVBAS library includes two special commands
  268.          that make this work extremely easy. The SCRSAVE and SCRREST
  269.          functions allow the virtually instantaneous transfer of screen
  270.          data to and from a numeric array. Once the array has been
  271.          dimensioned and the space reserved in memory, the entire screen
  272.          can be saved in just a fraction of a second. The window can then
  273.          be drawn anywhere on the screen without regard to the loss of
  274.          screen data. The SCRREST command performs the dual function of
  275.          erasing the window and restoring the screen's previous contents.
  276.          And all of this magic can be accomplished with just a few lines
  277.          of simple BASIC code.
  278.  
  279.          A typical use of the SCRSAVE and SCRREST commands would be as
  280.          follows:
  281.  
  282.                   10 OPTION BASE 1:DIM SCR%(4000)
  283.                   .
  284.                   .
  285.                   .
  286.                  100 WHER%=VARPTR(SCR(1)):CALL SCRSAVE(WHER%)
  287.                  110 CURSX%=pos(0):CURSY%=CSRLIN
  288.                   .
  289.                   .
  290.                   .
  291.                  150 REM Add window to screen
  292.                   .
  293.                   .
  294.                   .
  295.                  200 WHER%=VARPTR(SCR(1)):CALL SCRREST(WHER%)
  296.                  210 LOCATE CURSY%,CURSX%
  297.                   .
  298.                   .
  299.                   .
  300.  
  301.          While it is theoretically possible to maintain multiple arrays
  302.          to allow for several levels of non-destructive windows, each
  303.          array uses 8000 bytes and thus rapidly depletes free memory
  304.          space. Most programs can do nicely with only one array and one
  305.          level of windowing support.
  306.  
  307.          Scrolling and Clearing Data Inside a Window
  308.  
  309.          Another powerful feature made possible by the ADVBAS library is
  310.          the ability to scroll and clear a selected area of the screen,
  311.          independent of the rest of the data displayed. When combined
  312.          with the effective display techniques described above, this
  313.          impressive capability mimics that of expensive commercial prog-
  314.          rams. And best of all, the function calls are as easy to use as
  315.          the routines described above for BASWIND.
  316.  
  317.          The SCROLL and BKSCROLL commands take five parameters; four of
  318.          which are already defined as ULC,ULR,LRC,LRR in the BASWIND
  319.          window definition and display routine. Since the frame of the
  320.          window is drawn around the area defined by these coordinates,
  321.          the scrolling can take place within the confines of these
  322.          windows without any further complications. The fifth parameter,
  323.          the number of lines to scroll, is easily set. Most often, it
  324.          will only be one line; so that another line can be PRINTed into
  325.          its place either on the top or the bottom depending on whether
  326.          the scroll is up or down. In the special case that the number of
  327.          lines is zero, the entire area is cleared with spaces of the
  328.          background attribute; so an easy way of clearing a window is
  329.          available as well.
  330.  
  331.          As with the BASWIND parameters above, all of the SCROLL
  332.          variables must be integers. Thus, either a DEFINT statement must
  333.          be in place early in the program or the variables must carry the
  334.          "%" type identifier throughout the program.
  335.  
  336.          The program statements required to scroll up the contents of a
  337.          window defined and displayed by BASWIND would be as follows:
  338.  
  339.                   100 LINS=1
  340.                   110 CALL SCROLL(ULC,ULR,LRC,LRR,LINS)
  341.  
  342.          To scroll the same window down instead, the following series of
  343.          statements would be used:
  344.  
  345.                   100 LINS=1
  346.                   110 CALL BKSCROLL(ULC,ULR,LRC,LRR,LINS)
  347.  
  348.          And to clear the window of any data:
  349.  
  350.                   100 LINS=0
  351.                   110 CALL SCROLL(ULC,ULR,LRC,LRR,LINS)
  352.  
  353.          FURTHER ENHANCEMENTS
  354.  
  355.          The routines presented here allow a good start in providing
  356.          advanced windowing features in almost any compiled BASIC
  357.          program; but there is certainly room for improvements and
  358.          enhancements to these basic ideas. A few of which that come to
  359.          mind immediately are:
  360.  
  361.                 - Being able to move the window on the screen in real
  362.                   time under the control of the cursor keys. Such a
  363.                   procedure would involve rapidly restoring the orig-
  364.                   inal screen and redrawing the window at the updated
  365.                   position; something that seems feasible with the
  366.                   ADVBAS features.
  367.  
  368.                 - Adding clipping to the display of data in the window.
  369.                   For example, moving a window across a text file under
  370.                   cursor control.
  371.  
  372.                 - "Collapsing" windows which are removed from the screen
  373.                   in the opposite manner to "growing".
  374.  
  375.                 - A means of providing "point and select" functions with-
  376.                   in a window by moving a highlight bar up and down a 
  377.                   list of options.
  378.  
  379.          I am sure that with a little experimentation with these
  380.          routines, you will think of many more possibilities. Should you
  381.          come up with a routine that you like, please upload it to your
  382.          favorite bulletin board to help pass along this free exchange of
  383.          information. Drop me a line also, as I would like to keep up
  384.          with all of the developments these initial offerings inspire.
  385.  
  386.          COMPILING PROGRAMS
  387.  
  388.          As mentioned before, the routines in BASWIND and ADVBAS are
  389.          available only in Compiled BASIC. DON'T TRY TO USE THESE
  390.          PROGRAMS IN INTERPRETED BASIC!!!! At the very least, your
  391.          computer will probably lockup requiring a re-boot. At worst,
  392.          your system could go crazy, maybe even to the point of erasing
  393.          data on disks in the drive. You are forewarned!
  394.  
  395.          BASWIND requires no special handling when it comes to compiling
  396.          your program. Just make certain that all of your variables
  397.          passing parameters to the BASWIND subroutine are identified as
  398.          integers, and you will be able to proceed with the compile
  399.          operation as with any other program.
  400.  
  401.          The actual compilation of your program should be straight-
  402.          forward. However, once you get to the LINK operation, you MUST
  403.          remember to list ADVBAS in response to the LINK program's
  404.          request for library (LIB) files. Failure to do this will result
  405.          in unresolved external reference errors. This is true even if
  406.          you are using only BASWIND functions with no ADVBAS routines in
  407.          your program, since BASWIND uses the XQPRINT function in ADVBAS
  408.          as the heart of its operation.
  409.  
  410.          ACKNOWLEDGEMENTS
  411.  
  412.          As mentioned earlier, the ADVBAS.LIB library upon which all of
  413.          the routines in BASWIND.MRG are based was developed by Thomas
  414.          Hanlin III. For convenience sake, I have included this library
  415.          along with the accompanying .DOC file as part of the BASWIND.ARC
  416.          package. Tom has done an excellent job of providing many useful
  417.          features in an economical and well documented package. In the
  418.          .DOC file, Tom asks for a minimal contribution if you find these
  419.          routines useful. I have sent him my check; and I strongly urge
  420.          you to do so as well. To keep this spirit of information
  421.          exchange alive, those people who make such a generous effort
  422.          deserve to be rewarded. 
  423.  
  424.          I am deeply indebted to Tom for his routines which are key to
  425.          the operation of BASWIND. But as I look at my bank account, I
  426.          find that I am deeply indebted, period. Thus, I humbly request
  427.          that if you find BASWIND to be of some use to you that you
  428.          acknowledge your appreciation in a similar contribution of $10.
  429.          Unlike Tom, I don't guarantee you anything back for your money.
  430.          I don't have any other programs to give you; and I've included
  431.          all the source code in this package. But I do promise that I'll
  432.          like you a lot if you do send me money. And just the fact that I
  433.          haven't burdened down the code with a message that pops on the
  434.          screen and begs for money until you "PRESS ANY KEY TO CONTINUE"
  435.          ought to be worth something!
  436.  
  437.          Whether or not you feel BASWIND is worth anything, please feel
  438.          free to use it to your hearts content; copy it shamelessly and
  439.          give it to all your friends and enemies; use it in your
  440.          commercial programs and sell them for hundreds of thousands of
  441.          dollars. But whatever you do, keep contributing to the Public
  442.          Domain and FreeWare/ShareWare community. The best people in the
  443.          world live here!
  444.  
  445.  
  446.          Dave Evers
  447.          2500 Larch Rd. #58
  448.          Quincy, IL  62301
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.                             DISCLAIMER OF LIABILITY
  459.  
  460.  
  461.  
  462.          I, David Evers, as author of the BASWIND.MRG subroutine
  463.          contained in this package, hereby disclaim all responsibility
  464.          for any consequence arising from the use, misuse, or non-use of
  465.          any of the materials included herein. If this scares you and you
  466.          feel that you can't in good conscience use this product without
  467.          deposits and bonds and insurance policies for millions of
  468.          dollars, THEN DON'T USE THIS SOFTWARE. If you are afraid that
  469.          use of this product will damage your reputation, turn your green
  470.          screen monitor amber, change your house AC voltage from 110 to
  471.          220, or make your hair fall out; THEN DON'T USE THIS SOFTWARE.
  472.          And if by chance you DO use this software, and your spouse
  473.          leaves you, your children sell the house, your health fails, and
  474.          your hard disk crashes, THEN DON'T COME CRYING TO ME. With this
  475.          software, "you don't pays your money, but you still takes your
  476.          chances"!
  477.  
  478.  
  479.  
  480. ME CRYING TO ME. With this
  481.          software, "you don't pays your money, but you still takes your
  482.